package com.ruoyi.truth.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.truth.domain.CreUser;
import com.ruoyi.truth.service.ICreUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 征构信息Controller
 * 
 * @author ruoyi
 * @date 2023-07-04
 */
@RestController
@RequestMapping("/system/crehome")
public class CreUserController extends BaseController
{
    @Autowired
    private ICreUserService creUserService;

    /**
     * 查询征构信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:crehome:list')")
    @GetMapping("/list")
    public TableDataInfo list(CreUser creUser)
    {
        startPage();
        List<CreUser> list = creUserService.selectCreUserList(creUser);
        return getDataTable(list);
    }

    /**
     * 导出征构信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:crehome:export')")
    @Log(title = "征构信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CreUser creUser)
    {
        List<CreUser> list = creUserService.selectCreUserList(creUser);
        ExcelUtil<CreUser> util = new ExcelUtil<CreUser>(CreUser.class);
        util.exportExcel(response, list, "征构信息数据");
    }

    /**
     * 获取征构信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:crehome:query')")
    @GetMapping(value = "/{creUserid}")
    public AjaxResult getInfo(@PathVariable("creUserid") Long creUserid)
    {
        return success(creUserService.selectCreUserByCreUserid(creUserid));
    }

    /**
     * 新增征构信息
     */
    @PreAuthorize("@ss.hasPermi('system:crehome:add')")
    @Log(title = "征构信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CreUser creUser)
    {
        return toAjax(creUserService.insertCreUser(creUser));
    }

    /**
     * 修改征构信息
     */
    @PreAuthorize("@ss.hasPermi('system:crehome:edit')")
    @Log(title = "征构信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CreUser creUser)
    {
        return toAjax(creUserService.updateCreUser(creUser));
    }

    /**
     * 删除征构信息
     */
    @PreAuthorize("@ss.hasPermi('system:crehome:remove')")
    @Log(title = "征构信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{creUserids}")
    public AjaxResult remove(@PathVariable Long[] creUserids)
    {
        return toAjax(creUserService.deleteCreUserByCreUserids(creUserids));
    }
}
